
<article class="cl pd-20" >
    <form  class="form form-horizontal" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-3 " style="text-align: center;"><span class="c-red">*</span>父节点：</label>
            <div class="formControls col-xs-7 ">
                <input type="hidden" name="pid" th:value="${pid}"/>
                <input type="text" class="input-text" th:value="${name}" readonly="readonly"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 " style="text-align: center;"><span class="c-red">*</span>权限名称：</label>
            <div class="formControls col-xs-7 ">
                <input type="text" class="input-text" value="" placeholder="" id="name" name="name" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 " style="text-align: center;"><span class="c-red">*</span>权限URL：</label>
            <div class="formControls col-xs-7 ">
                <input type="text" class="input-text" value="" placeholder="" id="url" name="url" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 " style="text-align: center;"> 描述：</label>
            <div class="formControls col-xs-7 ">
                <textarea name="description" cols="" rows="" class="textarea" placeholder="说点什么..."></textarea>
            </div>
        </div>
        <!--这里可以直接给权限关联角色-->
        <!--<div class="row cl">-->
            <!--<label class="form-label col-xs-3 " style="text-align: center;">角色：</label>-->
            <!--<div class="formControls col-xs-7 ">-->
                <!--<select name="roles" id="roles" multiple="multiple" style="width: 250px;">-->
                <!--<option th:each="role:${roles}" th:value="${role.id}"-->
                        <!--th:text="${role.name}"-->
                <!--&gt;</option>-->
                <!--</select>-->
            <!--</div>-->
        <!--</div>-->

        <div class="row cl">
            <div class="col-xs-8 col-xs-offset-3">
                <input class="btn btn-primary radius" id="submit" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" />
            </div>
        </div>



    </form>
</article>


    <script type="text/javascript" th:src="@{/H-UI/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
    <script type="text/javascript" th:src="@{/H-UI/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
    <script>
        $(function(){
            $("#form-add").validate({
                rules:{
                    name:{required:true},
                    url:{required:true}


                },message:{
                    name:{required:"必填"}
                }
            });

            $("#submit").on('click',function(){
                if($("#form-add").valid()){


                    $.ajax({
                        url:"/permission/save",
                        type:"post",
                        dataType:'json',
                        data:$("#form-add").serialize(),
                        success:function(data){

                            if(data ==1){
                                var index = layer.index;
                                location.replace(location.href);
                                layer.close(index);
                             }
                        }
                    });

                }
            });



        });

    </script>

